package com.example.send.util;

import com.google.common.collect.Range;
import com.google.common.collect.RangeMap;
import com.google.common.collect.TreeRangeMap;

import java.util.*;

public class Division3Util {

    public static void main(String[] args) throws InterruptedException {
        Map<String, Double> geMap = new HashMap<>();
        Map<Double, List<String>> reverseMap = new HashMap<>();
        List<Double> keys = new ArrayList<>();
        for (int i = 10; i <= 99; i++) {
            for (int j = 10; j <= 99; j++) {
                int value = (int) Math.round(i * 1000.0 / j);
                System.out.println(i + "/" + j + " " + value / 10.0 + "%");
                double key = value / 10.0;
                reverseMap.putIfAbsent(key, new ArrayList<>());
                reverseMap.get(key).add(i + "/" + j);
                if (!keys.contains(key)) {
                    keys.add(key);
                }
                geMap.put(i + "/" + j, value / 1000.0);
            }
        }
        keys.sort(Comparator.naturalOrder());
        for (double key : keys) {
            List<String> strs = reverseMap.get(key);
            if (strs == null && strs.size() == 0) {
                System.out.println("错误：" + key);
            }
            for (String str : strs) {
                System.out.println(key + "% " + str);
            }
        }
        while (true) {
            System.out.println("********************************************");
            int v1 = (int) (10 + Math.random() * (99 - 10 + 1));
            int v2 = (int) (10 + Math.random() * (99 - 10 + 1));
            System.out.println(v1);
            System.out.println("---");
            System.out.println(v2);

            Thread.sleep(3000);
            String key = v1 + "/" + v2;
            double dVal = geMap.get(key);
            System.out.println("real: " + dVal * 100 + "%");
            System.out.println("********************************************");
            Thread.sleep(3000);
        }


    }

}
